<?php

class Waiter
{
    private $commend_list;

    public function setOrder(Command $command)
    {
        $this->commend_list[] = $command;
        fwrite(STDOUT, '增加订单：' . $command->getName() . "\n");
    }

    public function removeOrder(Command $command)
    {
        $index = array_search($command, $this->commend_list);
        if ($index !== false) {
            unset($this->commend_list[$index]);
            fwrite(STDOUT, '取消订单：' . $command->getName() . "\n");
        }
    }

    public function notify()
    {
        foreach ($this->commend_list as $commend) {
            $commend->executeCommend();
        }
    }
}